﻿using System;
using NUnit.Framework;
using Whois.API;

namespace Tests.APITests
{
    public class WhoisTests : APITestBase
    {
        [Test]
        public void CoUkDomain()
        {
            var service = new XmlService(Username, Password, UrlFormat);
            var result = service.GetResponse("lemondehotel.co.uk");
            Assert.IsNotNull(result);
            Assert.IsNotNull(result.RegistryData);
            Assert.IsNotNull(result.RegistryData.ExpiresDate);
            Assert.IsNotNull(result.RegistryData.StrippedText);

        }
        [Test]
        public void ComDomain()
        {
            var service = new XmlService(Username, Password, UrlFormat);
            var result = service.GetResponse("AngelsShareHotel.com");
            Assert.IsNotNull(result);
            Assert.IsNotNull(result.RegistryData);
            Assert.IsNotNull(result.RegistryData.ExpiresDate);
            Assert.IsNotNull(result.RegistryData.StrippedText);

        }

        [Test]
        public void Microsoft()
        {
            var service = new XmlService(Username, Password, UrlFormat);
            var result = service.GetResponse("microsoft.com");
            Assert.IsNotNull(result);
            Assert.IsNotNull(result.RegistryData);
            Assert.IsNotNull(result.RegistryData.ExpiresDate);
            Assert.GreaterOrEqual(result.RegistryData.ExpiresDate, DateTime.Now, "Oh darn, Microsoft domain expired");
        }

        [Test]
        public void Google()
        {
            var service = new XmlService(Username, Password, UrlFormat);
            var result = service.GetResponse("google.com");
            Assert.IsNotNull(result);
            Assert.IsNotNull(result.RegistryData);
            Assert.IsNotNull(result.RegistryData.ExpiresDate);
            Assert.GreaterOrEqual(result.RegistryData.ExpiresDate, DateTime.Now, "Gooooooooo expired");
        }

        [Test]
        public void Twitter()
        {
            var service = new XmlService(Username, Password, UrlFormat);
            var result = service.GetResponse("twitter.com");
            Assert.IsNotNull(result);
            Assert.IsNotNull(result.RegistryData);
            Assert.IsNotNull(result.RegistryData.ExpiresDate);
            Assert.GreaterOrEqual(result.RegistryData.ExpiresDate, DateTime.Now, ":-D");
        }
    }
}
